﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Presentation.Models.SubprojectViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	View
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2><%: Model.Subproject.Name%></h2>
    <%: Model.errmsg %>
    <%: Model.Subproject.Description%>

    <h3>Details</h3>

    <div>
                
        <table>
                
            <tr>
                <td>
                    <%: Html.LabelFor(m => m.Subproject.Status)%>:
                </td>
                <td align="center">
                    <img src="../../Assets/<%: Model.Subproject.Status.StatusIndicator %>.png" height="20px" width="20px" alt="<%: Model.Subproject.Status.StatusIndicator %>" />
                </td>
            </tr>

            <% 
           
                foreach (var formElement in Model.Form.FormElements)
                {
                    var index = Model.Subproject.GetDetailIndex(formElement.Name);
                        
                    if (index != -1)
                    {
                        var detail = Model.Subproject.Details[index];
                            
                        if (formElement.Type.Equals(Domain.Model.FormElement.TYPE_CHAR))
                        { 
                        %>
                                        
                            <tr>
                                            
                                <td>
                                    <%: Html.Label(Model.Subproject.Details[index].Name)%>:
                                </td>
                                <td>
                                    <%: Html.Label(Model.Subproject.Details[index].Value)%>
                                </td>

                            </tr>
                                        
                        <%
                        }
                        if (formElement.Type.Equals(Domain.Model.FormElement.TYPE_NUMERIC))
                        {
                         %>
                                        
                            <tr>
                                            
                                <td>
                                    <%: Html.Label(Model.Subproject.Details[index].Name)%>:
                                </td>
                                <td>
                                    <%: Html.Label(Model.Subproject.Details[index].Value)%>
                                </td>

                            </tr>
                                        
                        <%
                        }
                        if (formElement.Type.Equals(Domain.Model.FormElement.TYPE_DATE))
                        {
                        %>
                                        
                            <tr>
                                            
                                <td>
                                    <%: Html.Label(Model.Subproject.Details[index].Name)%>:
                                </td>
                                <td>
                                    <%: Html.Label(Model.Subproject.Details[index].Value)%>
                                </td>

                            </tr>
                                        
                        <%
                        }
                    }
                }
                    
            %>

        </table>

    </div>

    <div>
        <p>
            <%: Html.ActionLink("Back to project", "View", "Project", new { id = Model.ProjectId }, null) %> |
            <% if (Helpers.IsAdmin(this)){%>
                <%: Html.ActionLink("Edit", "Edit", "Subproject", new { id = Model.Subproject.Id }, null) %>
            <% } %>
        </p>
    </div>

    <p>&nbsp;</p>

    <table>
        <tr>
            <th>Tasks</th>
        </tr>
        <tr valign="top">
            <td>
                <% Html.RenderPartial("ReadOnlyTaskList", Model.Subproject.Tasks); %>
            </td>
        </tr>
    </table>

</asp:Content>
